<%@page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<link href="resources/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"
      type="text/css" />
<script src="resources/ztree/js/jquery.ztree.all-3.5.min.js"
        type="text/javascript"></script>
<script src="resources/jquery.json-2.3.js" type="text/javascript"></script>
<SCRIPT type="text/javascript">
    <!--
    var setting = {
        callback: {
            onNodeCreated: zTreeOnNodeCreated
        },
        data : {
            simpleData : {
                idKey : "id",
                pIdKey : "pid",
                enable : true
            }
        }
    };

    function zTreeOnNodeCreated(event, treeId, treeNode) {
        //如果不是叶子节点
        if(!treeNode.isParent){
            $("#"+treeNode.tId+"_a").live("click",function(){
                $.bringBack({id:treeNode.id,name:treeNode.name});
            });
        }
    }

    function loadMenuTree() {
        $.ajax({
            async : false,
            cache : false,
            type : 'POST',
            dataType : "json",
            url : "${ctx}/category/dotree",//请求的action路径
            error : function() {//请求失败处理函数
                alert('请求失败');
            },
            success : function(data) { //请求成功后处理函数。
                var treeObj = $.fn.zTree.init($("#treeDemo"), setting, data);
                treeObj.expandAll(true);
            }
        });

    }

        $(document).ready(function() {
            loadMenuTree();
        });
    //-->
</SCRIPT>
<div class="pageContent">
    <ul id="treeDemo" class="ztree" ></ul>
</div>